package 剑指Offer1;

public class _25删除链表的节点 {
    public class ListNode {
       int val;
       ListNode next;
       ListNode(int x) { val = x; }
     }
    public ListNode deleteNode(ListNode head, int val) {
        if(head == null) return null;
        if(head.val == val) return head.next;
        for(ListNode tmp = head;tmp!=null && tmp.next!=null;tmp = tmp.next){
            if(tmp.next.val == val){
                tmp.next = tmp.next.next;
            }
        }
        return head;
    }
}
